package com.example.springboot.security;

import cn.hutool.crypto.digest.DigestUtil;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * 密码加密
 * @default
**/
public class DefaultPasswordEncoder implements PasswordEncoder {

    public DefaultPasswordEncoder(){
        this(-1);
    }

    public DefaultPasswordEncoder(int length){

    }

    /**
     * 加密
     * @default
    **/
    @Override
    public String encode(CharSequence charSequence) {
        return DigestUtil.md5Hex(charSequence.toString());
    }
    /**
     * 密码对比
     * @default
    **/
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(charSequence.toString());
    }

}
